bitkeeper revision 1.987 (40d595643wZIEtMwb3hHvNEGMAu8gQ)
authorkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Sun, 20 Jun 2004 13:47:16 +0000 (13:47 +0000)
committerkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Sun, 20 Jun 2004 13:47:16 +0000 (13:47 +0000)
Fix the getdomaininfo dom0_op.

tools/examples/xc_dom_control.py
tools/xc/lib/xc.h
tools/xc/lib/xc_domain.c
tools/xc/lib/xc_linux_build.c
tools/xc/lib/xc_netbsd_build.c
tools/xc/py/Xc.c
tools/xenmgr/lib/XendDomainInfo.py
xen/common/dom0_ops.c
xen/common/domain.c
xen/include/hypervisor-ifs/dom0_ops.h
xen/include/xen/sched.h

index 56c6fb852e8679c6a1dee893755c8261f984a660..5f74077b12bcf0a0e449d8b9c886b08db1d3cf7a 100755 (executable)
@@ -88,10 +88,13 @@ elif cmd == 'list':
     print 'Dom  Name             Mem(kb)  CPU  State  Time(ms)'
     for domain in xc.domain_getinfo():
 
-       run = (domain['running'] and 'r') or '-'                # domain['running'] ? run='r' : run='-'
-       stop = (domain['stopped'] and 's') or '-'               # domain['stopped'] ? stop='s': stop='-'
+       run   = (domain['running'] and 'r') or '-'
+        block = (domain['blocked'] and 'b') or '-'
+       stop  = (domain['stopped'] and 's') or '-'
+       susp  = (domain['suspended'] and 'S') or '-'
+       crash = (domain['crashed'] and 'c') or '-'
 
-        domain['state'] = run + stop
+        domain['state'] = run + block + stop + susp + crash
         domain['cpu_time'] = domain['cpu_time']/1e6
 
         print "%(dom)-4d %(name)-16s %(mem_kb)7d %(cpu)3d %(state)5s %(cpu_time)8d" % domain
index 7ca6ba9dda960c6234931110e554ec9474c0f683..1ca7ead8d0c4377574181d91f7a1194abcfe8aa7 100644 (file)
@@ -25,8 +25,8 @@ int xc_interface_close(int xc_handle);
 typedef struct {
     u32           domid;
     unsigned int  cpu;
-    int           has_cpu;
-    int           stopped;
+    unsigned int  dying:1, crashed:1, suspended:1, 
+                  stopped:1, blocked:1, running:1;
     unsigned long nr_pages;
     unsigned long shared_info_frame;
     u64           cpu_time;
index ae9c86e341ef41f2a371b59d615b3afe1bc779c9..a0e222718d78679548ac79b8b57d813eecc006f9 100644 (file)
@@ -93,11 +93,13 @@ int xc_domain_getinfo(int xc_handle,
 
         info->cpu     =
             (op.u.getdomaininfo.flags>>DOMFLAGS_CPUSHIFT) & DOMFLAGS_CPUMASK;
-        info->has_cpu =
-            (op.u.getdomaininfo.flags&DOMFLAGS_STATEMASK) == DOMSTATE_RUNNING;
-        info->stopped = 
-            (op.u.getdomaininfo.flags&DOMFLAGS_STATEMASK)
-            == DOMSTATE_SUSPENDED;
+
+        info->dying     = (op.u.getdomaininfo.flags & DOMFLAGS_DYING);
+        info->crashed   = (op.u.getdomaininfo.flags & DOMFLAGS_CRASHED);
+        info->suspended = (op.u.getdomaininfo.flags & DOMFLAGS_SUSPENDED);
+        info->stopped   = (op.u.getdomaininfo.flags & DOMFLAGS_STOPPED);
+        info->blocked   = (op.u.getdomaininfo.flags & DOMFLAGS_BLOCKED);
+        info->running   = (op.u.getdomaininfo.flags & DOMFLAGS_RUNNING);
 
         info->nr_pages = op.u.getdomaininfo.tot_pages;
         info->max_memkb = op.u.getdomaininfo.max_pages<<(PAGE_SHIFT-10);
index 76c5f5f1f2aa9a23e341758f6f236cc33a007785..16d0dbb9d1ab017afb73e2f1c10f689933d583e6 100644 (file)
@@ -436,7 +436,7 @@ int xc_linux_build(int xc_handle,
         PERROR("Could not get info on domain");
         goto error_out;
     }
-    if ( ((op.u.getdomaininfo.flags&DOMFLAGS_STATEMASK) != DOMSTATE_PAUSED) ||
+    if ( !(op.u.getdomaininfo.flags & DOMFLAGS_STOPPED) ||
          (ctxt->pt_base != 0) )
     {
         ERROR("Domain is already constructed");
index ba4b3e39e45f039aa0a36ea8f688ef050c791a7f..a0c73fa1bc3b78b158d85bb1954b1239b4d141e0 100644 (file)
@@ -258,7 +258,7 @@ int xc_netbsd_build(int xc_handle,
         PERROR("Could not get info on domain");
         goto error_out;
     }
-    if ( ((op.u.getdomaininfo.flags&DOMFLAGS_STATEMASK) != DOMSTATE_PAUSED) ||
+    if ( !(op.u.getdomaininfo.flags & DOMFLAGS_STOPPED) ||
          (op.u.getdomaininfo.ctxt->pt_base != 0) )
     {
         ERROR("Domain is already constructed");
index 7e904fc9736c76d967a35fc93e34b04ea6f17da8..b32d456b2ce1b67b59ad48a3a03c4b74dcfc8407 100644 (file)
@@ -167,14 +167,18 @@ static PyObject *pyxc_domain_getinfo(PyObject *self,
         PyList_SetItem(
             list, i, 
             Py_BuildValue("{s:i,s:i,s:i,s:i,s:l,s:L,s:s,s:l}",
-                          "dom",      info[i].domid,
-                          "cpu",      info[i].cpu,
-                          "running",  info[i].has_cpu,
-                          "stopped",  info[i].stopped,
-                          "mem_kb",   info[i].nr_pages*4,
-                          "cpu_time", info[i].cpu_time,
-                          "name",     info[i].name,
-                          "maxmem_kb",info[i].max_memkb
+                          "dom",       info[i].domid,
+                          "cpu",       info[i].cpu,
+                          "dying",     info[i].dying,
+                          "crashed",   info[i].crashed,
+                          "suspended", info[i].suspended,
+                          "stopped",   info[i].stopped,
+                          "blocked",   info[i].blocked,
+                          "running",   info[i].running,
+                          "mem_kb",    info[i].nr_pages*4,
+                          "cpu_time",  info[i].cpu_time,
+                          "name",      info[i].name,
+                          "maxmem_kb", info[i].max_memkb
                 ));
     }
 
@@ -1053,8 +1057,12 @@ static PyMethodDef pyxc_methods[] = {
       "         domain-id space was reached.\n"
       " dom      [int]: Identifier of domain to which this info pertains\n"
       " cpu      [int]:  CPU to which this domain is bound\n"
+      " dying    [int]:  Bool - is the domain dying?\n"
+      " crashed  [int]:  Bool - has the domain crashed?\n"
+      " suspended[int]:  Bool - has the domain suspended itself?\n"
+      " stopped  [int]:  Bool - is the domain stopped by control software?\n"
+      " blocked  [int]:  Bool - is the domain blocked waiting for an event?\n"
       " running  [int]:  Bool - is the domain currently running?\n"
-      " stopped  [int]:  Bool - is the domain suspended?\n"
       " mem_kb   [int]:  Memory reservation, in kilobytes\n"
       " cpu_time [long]: CPU time consumed, in nanoseconds\n"
       " name     [str]:  Identifying name\n" },
index b03d83a15db331a12151c442eb56e88a1e55698a..61a9b21c5a801ac1a17d896954732a3353d21673 100644 (file)
@@ -111,9 +111,12 @@ class XendDomainInfo:
                 ['name', self.name],
                 ['memory', self.memory] ]
         if self.info:
-            run = (self.info['running'] and 'r') or '-'
-            stop = (self.info['stopped'] and 's') or '-'
-            state = run + stop
+            run   = (self.info['running'] and 'r') or '-'
+            block = (self.info['blocked'] and 'b') or '-'
+            stop  = (self.info['stopped'] and 's') or '-'
+            susp  = (self.info['suspended'] and 'S') or '-'
+            crash = (self.info['crashed'] and 'c') or '-'
+            state = run + block + stop + susp + crash
             sxpr.append(['cpu', self.info['cpu']])
             sxpr.append(['state', state])
             sxpr.append(['cpu_time', self.info['cpu_time']/1e9])
index 5128b150700cb47e95f525787db11f2ec4a038b1..e7ac6a085d4e511d56eed92b98d6e174c4ec10fd 100644 (file)
@@ -46,7 +46,7 @@ static void read_msr_for(void *unused)
 long do_dom0_op(dom0_op_t *u_dom0_op)
 {
     long ret = 0;
-    dom0_op_t curop,*op=&curop;
+    dom0_op_t curop, *op = &curop;
 
     if ( !IS_PRIV(current) )
         return -EPERM;
@@ -70,12 +70,12 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
 
     case DOM0_BUILDDOMAIN:
     {
-        struct domain * p = find_domain_by_id(op->u.builddomain.domain);
+        struct domain *d = find_domain_by_id(op->u.builddomain.domain);
         ret = -EINVAL;
-        if ( p != NULL )
+        if ( d != NULL )
         {
-            ret = final_setup_guestos(p, &op->u.builddomain);
-            put_domain(p);
+            ret = final_setup_guestos(d, &op->u.builddomain);
+            put_domain(d);
         }
     }
     break;
@@ -112,11 +112,12 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
 
     case DOM0_CREATEDOMAIN:
     {
-        struct domain *p;
+        struct domain    *d;
         static domid_t    domnr = 0;
         static spinlock_t domnr_lock = SPIN_LOCK_UNLOCKED;
-        unsigned int pro;
-        domid_t dom;
+        unsigned int      pro;
+        domid_t           dom;
+
         ret = -ENOMEM;
 
         /* Search for an unused domain identifier. */
@@ -128,36 +129,36 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
                 dom = domnr = 1;
             spin_unlock(&domnr_lock);
 
-            if ( (p = find_domain_by_id(dom)) == NULL )
+            if ( (d = find_domain_by_id(dom)) == NULL )
                 break;
-            put_domain(p);
+            put_domain(d);
         }
 
-        if (op->u.createdomain.cpu == -1 )
+        if ( op->u.createdomain.cpu == -1 )
             pro = (unsigned int)dom % smp_num_cpus;
         else
             pro = op->u.createdomain.cpu % smp_num_cpus;
 
-        p = do_createdomain(dom, pro);
-        if ( p == NULL ) 
+        d = do_createdomain(dom, pro);
+        if ( d == NULL ) 
             break;
 
         if ( op->u.createdomain.name[0] )
         {
-            strncpy(p->name, op->u.createdomain.name, MAX_DOMAIN_NAME);
-            p->name[MAX_DOMAIN_NAME - 1] = '\0';
+            strncpy(d->name, op->u.createdomain.name, MAX_DOMAIN_NAME);
+            d->name[MAX_DOMAIN_NAME - 1] = '\0';
         }
 
-        ret = alloc_new_dom_mem(p, op->u.createdomain.memory_kb);
+        ret = alloc_new_dom_mem(d, op->u.createdomain.memory_kb);
         if ( ret != 0 ) 
         {
-            domain_kill(p);
+            domain_kill(d);
             break;
         }
 
         ret = 0;
         
-        op->u.createdomain.domain = p->domain;
+        op->u.createdomain.domain = d->domain;
         copy_to_user(u_dom0_op, op, sizeof(*op));
     }
     break;
@@ -187,26 +188,26 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
             ret = -EINVAL;
         else
         {
-            struct domain * p = find_domain_by_id(dom);
+            struct domain *d = find_domain_by_id(dom);
             int cpu = op->u.pincpudomain.cpu;
             
             ret = -ESRCH;
             
-            if ( p != NULL )
+            if ( d != NULL )
             {
                 if ( cpu == -1 )
                 {
-                    clear_bit(DF_CPUPINNED, &p->flags);
+                    clear_bit(DF_CPUPINNED, &d->flags);
                 }
                 else
                 {
-                    domain_pause(p);
-                    set_bit(DF_CPUPINNED, &p->flags);
+                    domain_pause(d);
+                    set_bit(DF_CPUPINNED, &d->flags);
                     cpu = cpu % smp_num_cpus;
-                    p->processor = cpu;
-                    domain_unpause(p);
+                    d->processor = cpu;
+                    domain_unpause(d);
                 }
-                put_domain(p);
+                put_domain(d);
                 ret = 0;
             }      
         }
@@ -230,20 +231,20 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
     case DOM0_GETMEMLIST:
     {
         int i;
-        struct domain *p = find_domain_by_id(op->u.getmemlist.domain);
+        struct domain *d = find_domain_by_id(op->u.getmemlist.domain);
         unsigned long max_pfns = op->u.getmemlist.max_pfns;
         unsigned long pfn;
         unsigned long *buffer = op->u.getmemlist.buffer;
         struct list_head *list_ent;
 
         ret = -EINVAL;
-        if ( p != NULL )
+        if ( d != NULL )
         {
             ret = 0;
 
-            spin_lock(&p->page_list_lock);
-            list_ent = p->page_list.next;
-            for ( i = 0; (i < max_pfns) && (list_ent != &p->page_list); i++ )
+            spin_lock(&d->page_list_lock);
+            list_ent = d->page_list.next;
+            for ( i = 0; (i < max_pfns) && (list_ent != &d->page_list); i++ )
             {
                 pfn = list_entry(list_ent, struct pfn_info, list) - 
                     frame_table;
@@ -255,12 +256,12 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
                 buffer++;
                 list_ent = frame_table[pfn].list.next;
             }
-            spin_unlock(&p->page_list_lock);
+            spin_unlock(&d->page_list_lock);
 
             op->u.getmemlist.num_pfns = i;
             copy_to_user(u_dom0_op, op, sizeof(*op));
             
-            put_domain(p);
+            put_domain(d);
         }
     }
     break;
@@ -268,126 +269,118 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
     case DOM0_GETDOMAININFO:
     { 
         full_execution_context_t *c;
-        struct domain       *p;
+        struct domain            *d;
         unsigned long             flags;
-        int                       i, dump_state = 0;
+        int                       i;
 
         read_lock_irqsave(&tasklist_lock, flags);
 
-        for_each_domain ( p )
+        for_each_domain ( d )
         {
-            if ( p->domain >= op->u.getdomaininfo.domain )
+            if ( d->domain >= op->u.getdomaininfo.domain )
                 break;
         }
 
-        if ( p == NULL )
+        if ( (d == NULL) || !get_domain(d) )
         {
+            read_unlock_irqrestore(&tasklist_lock, flags);
             ret = -ESRCH;
-            goto gdi_out;
+            break;
         }
-        else
-        {
-            op->u.getdomaininfo.domain = p->domain;
-            strcpy(op->u.getdomaininfo.name, p->name);
-
-            /* These are kind of in order of 'importance'. */
-            if ( test_bit(DF_CRASHED, &p->flags) )
-                op->u.getdomaininfo.flags = DOMSTATE_CRASHED;
-            else if ( test_bit(DF_SUSPENDED, &p->flags) )
-                op->u.getdomaininfo.flags = DOMSTATE_SUSPENDED;
-            else if ( test_bit(DF_STOPPED, &p->flags) )
-                op->u.getdomaininfo.flags = DOMSTATE_PAUSED;
-            else if ( test_bit(DF_BLOCKED, &p->flags) )
-                op->u.getdomaininfo.flags = DOMSTATE_BLOCKED;
-            else if ( test_bit(DF_RUNNING, &p->flags) )
-            {
-                op->u.getdomaininfo.flags = DOMSTATE_RUNNING;
-                dump_state = 1;
-            }
-            else
-            {
-                op->u.getdomaininfo.flags = DOMSTATE_RUNNABLE;
-                dump_state = 1;
-            }
 
-            op->u.getdomaininfo.flags |= p->processor << DOMFLAGS_CPUSHIFT;
-            op->u.getdomaininfo.flags |= p->stop_code << DOMFLAGS_GUESTSHIFT;
+        op->u.getdomaininfo.flags =
+            (test_bit(DF_RUNNING, &d->flags) ? DOMFLAGS_RUNNING : 0);
 
-            op->u.getdomaininfo.tot_pages   = p->tot_pages;
-            op->u.getdomaininfo.max_pages   = p->max_pages;
-            op->u.getdomaininfo.cpu_time    = p->cpu_time;
-            op->u.getdomaininfo.shared_info_frame = 
-                __pa(p->shared_info) >> PAGE_SHIFT;
+        domain_pause(d);
 
-            if ( dump_state && (op->u.getdomaininfo.ctxt != NULL) )
+        op->u.getdomaininfo.domain = d->domain;
+        strcpy(op->u.getdomaininfo.name, d->name);
+        
+        op->u.getdomaininfo.flags |=
+            (test_bit(DF_DYING,     &d->flags) ? DOMFLAGS_DYING     : 0) |
+            (test_bit(DF_CRASHED,   &d->flags) ? DOMFLAGS_CRASHED   : 0) |
+            (test_bit(DF_SUSPENDED, &d->flags) ? DOMFLAGS_SUSPENDED : 0) |
+            (test_bit(DF_STOPPED,   &d->flags) ? DOMFLAGS_STOPPED   : 0) |
+            (test_bit(DF_BLOCKED,   &d->flags) ? DOMFLAGS_BLOCKED   : 0);
+
+        op->u.getdomaininfo.flags |= d->processor << DOMFLAGS_CPUSHIFT;
+        op->u.getdomaininfo.flags |= 
+            d->suspend_code << DOMFLAGS_SUSPCODESHIFT;
+
+        op->u.getdomaininfo.tot_pages   = d->tot_pages;
+        op->u.getdomaininfo.max_pages   = d->max_pages;
+        op->u.getdomaininfo.cpu_time    = d->cpu_time;
+        op->u.getdomaininfo.shared_info_frame = 
+            __pa(d->shared_info) >> PAGE_SHIFT;
+
+        if ( op->u.getdomaininfo.ctxt != NULL )
+        {
+            if ( (c = kmalloc(sizeof(*c), GFP_KERNEL)) == NULL )
             {
-                if ( (c = kmalloc(sizeof(*c), GFP_KERNEL)) == NULL )
-                {
-                    ret = -ENOMEM;
-                    goto gdi_out;
-                }
+                ret = -ENOMEM;
+                goto gdi_out;
+            }
 
-                rmb(); /* Ensure that we see saved register state. */
-                c->flags = 0;
-                memcpy(&c->cpu_ctxt, 
-                       &p->shared_info->execution_context,
-                       sizeof(p->shared_info->execution_context));
-                if ( test_bit(DF_DONEFPUINIT, &p->flags) )
-                    c->flags |= ECF_I387_VALID;
-                memcpy(&c->fpu_ctxt,
-                       &p->thread.i387,
-                       sizeof(p->thread.i387));
-                memcpy(&c->trap_ctxt,
-                       p->thread.traps,
-                       sizeof(p->thread.traps));
+            c->flags = 0;
+            memcpy(&c->cpu_ctxt, 
+                   &d->shared_info->execution_context,
+                   sizeof(d->shared_info->execution_context));
+            if ( test_bit(DF_DONEFPUINIT, &d->flags) )
+                c->flags |= ECF_I387_VALID;
+            memcpy(&c->fpu_ctxt,
+                   &d->thread.i387,
+                   sizeof(d->thread.i387));
+            memcpy(&c->trap_ctxt,
+                   d->thread.traps,
+                   sizeof(d->thread.traps));
 #ifdef ARCH_HAS_FAST_TRAP
-                if ( (p->thread.fast_trap_desc.a == 0) &&
-                     (p->thread.fast_trap_desc.b == 0) )
-                    c->fast_trap_idx = 0;
-                else
-                    c->fast_trap_idx = 
-                        p->thread.fast_trap_idx;
+            if ( (d->thread.fast_trap_desc.a == 0) &&
+                 (d->thread.fast_trap_desc.b == 0) )
+                c->fast_trap_idx = 0;
+            else
+                c->fast_trap_idx = 
+                    d->thread.fast_trap_idx;
 #endif
-                c->ldt_base = p->mm.ldt_base;
-                c->ldt_ents = p->mm.ldt_ents;
-                c->gdt_ents = 0;
-                if ( GET_GDT_ADDRESS(p) == GDT_VIRT_START )
-                {
-                    for ( i = 0; i < 16; i++ )
-                        c->gdt_frames[i] = 
-                            l1_pgentry_to_pagenr(p->mm.perdomain_pt[i]);
-                    c->gdt_ents = 
-                        (GET_GDT_ENTRIES(p) + 1) >> 3;
-                }
-                c->guestos_ss  = p->thread.guestos_ss;
-                c->guestos_esp = p->thread.guestos_sp;
-                c->pt_base   = 
-                    pagetable_val(p->mm.pagetable);
-                memcpy(c->debugreg, 
-                       p->thread.debugreg, 
-                       sizeof(p->thread.debugreg));
-                c->event_callback_cs  =
-                    p->event_selector;
-                c->event_callback_eip =
-                    p->event_address;
-                c->failsafe_callback_cs  = 
-                    p->failsafe_selector;
-                c->failsafe_callback_eip = 
-                    p->failsafe_address;
-
-                if ( copy_to_user(op->u.getdomaininfo.ctxt, c, sizeof(*c)) )
-                    ret = -EINVAL;
-
-                if ( c != NULL )
-                    kfree(c);
+            c->ldt_base = d->mm.ldt_base;
+            c->ldt_ents = d->mm.ldt_ents;
+            c->gdt_ents = 0;
+            if ( GET_GDT_ADDRESS(d) == GDT_VIRT_START )
+            {
+                for ( i = 0; i < 16; i++ )
+                    c->gdt_frames[i] = 
+                        l1_pgentry_to_pagenr(d->mm.perdomain_pt[i]);
+                c->gdt_ents = 
+                    (GET_GDT_ENTRIES(d) + 1) >> 3;
             }
+            c->guestos_ss  = d->thread.guestos_ss;
+            c->guestos_esp = d->thread.guestos_sp;
+            c->pt_base   = 
+                pagetable_val(d->mm.pagetable);
+            memcpy(c->debugreg, 
+                   d->thread.debugreg, 
+                   sizeof(d->thread.debugreg));
+            c->event_callback_cs  =
+                d->event_selector;
+            c->event_callback_eip =
+                d->event_address;
+            c->failsafe_callback_cs  = 
+                d->failsafe_selector;
+            c->failsafe_callback_eip = 
+                d->failsafe_address;
+
+            if ( copy_to_user(op->u.getdomaininfo.ctxt, c, sizeof(*c)) )
+                ret = -EINVAL;
+
+            if ( c != NULL )
+                kfree(c);
         }
 
         if ( copy_to_user(u_dom0_op, op, sizeof(*op)) )     
             ret = -EINVAL;
 
     gdi_out:
-        read_unlock_irqrestore(&tasklist_lock, flags);
+        domain_unpause(d);
+        put_domain(d);
     }
     break;
 
@@ -396,17 +389,17 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
         struct pfn_info *page;
         unsigned long pfn = op->u.getpageframeinfo.pfn;
         domid_t dom = op->u.getpageframeinfo.domain;
-        struct domain *p;
+        struct domain *d;
 
         ret = -EINVAL;
 
         if ( unlikely(pfn >= max_page) || 
-             unlikely((p = find_domain_by_id(dom)) == NULL) )
+             unlikely((d = find_domain_by_id(dom)) == NULL) )
             break;
 
         page = &frame_table[pfn];
 
-        if ( likely(get_page(page, p)) )
+        if ( likely(get_page(page, d)) )
         {
             ret = 0;
 
@@ -434,7 +427,7 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
             put_page(page);
         }
 
-        put_domain(p);
+        put_domain(d);
 
         copy_to_user(u_dom0_op, op, sizeof(*op));
     }
@@ -544,13 +537,13 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
 
     case DOM0_SHADOW_CONTROL:
     {
-        struct domain *p
+        struct domain *d
         ret = -ESRCH;
-        p = find_domain_by_id( op->u.shadow_control.domain );
-        if ( p )
+        d = find_domain_by_id(op->u.shadow_control.domain);
+        if ( d != NULL )
         {
-            ret = shadow_mode_control(p, &op->u.shadow_control );
-            put_domain(p);
+            ret = shadow_mode_control(d, &op->u.shadow_control);
+            put_domain(d);
             copy_to_user(u_dom0_op, op, sizeof(*op));
         } 
     }
@@ -559,7 +552,6 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
     case DOM0_SCHED_ID:
     {
         op->u.sched_id.sched_id = sched_id();
-
         copy_to_user(u_dom0_op, op, sizeof(*op));
         ret = 0;        
     }
@@ -567,48 +559,48 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
 
     case DOM0_SETDOMAINNAME:
     {
-        struct domain *p; 
-        p = find_domain_by_id( op->u.setdomainname.domain );
-        if ( p )
+        struct domain *d; 
+        ret = -ESRCH;
+        d = find_domain_by_id( op->u.setdomainname.domain );
+        if ( d != NULL )
         {
-            strncpy(p->name, op->u.setdomainname.name, MAX_DOMAIN_NAME);
-            put_domain(p);
+            strncpy(d->name, op->u.setdomainname.name, MAX_DOMAIN_NAME);
+            put_domain(d);
+            ret = 0;
         }
-        else 
-            ret = -ESRCH;
     }
     break;
 
     case DOM0_SETDOMAININITIALMEM:
     {
-        struct domain *p
+        struct domain *d
         ret = -ESRCH;
-        p = find_domain_by_id( op->u.setdomaininitialmem.domain );
-        if ( p )
+        d = find_domain_by_id(op->u.setdomaininitialmem.domain);
+        if ( d != NULL )
         { 
             /* should only be used *before* domain is built. */
-            if ( ! test_bit(DF_CONSTRUCTED, &p->flags) )
+            if ( !test_bit(DF_CONSTRUCTED, &d->flags) )
                 ret = alloc_new_dom_mem( 
-                    p, op->u.setdomaininitialmem.initial_memkb );
+                    d, op->u.setdomaininitialmem.initial_memkb );
             else
                 ret = -EINVAL;
-            put_domain(p);
+            put_domain(d);
         }
     }
     break;
 
     case DOM0_SETDOMAINMAXMEM:
     {
-        struct domain *p; 
-        p = find_domain_by_id( op->u.setdomainmaxmem.domain );
-        if ( p )
+        struct domain *d; 
+        ret = -ESRCH;
+        d = find_domain_by_id( op->u.setdomainmaxmem.domain );
+        if ( d != NULL )
         {
-            p->max_pages = 
+            d->max_pages = 
                 (op->u.setdomainmaxmem.max_memkb+PAGE_SIZE-1)>> PAGE_SHIFT;
-            put_domain(p);
+            put_domain(d);
+            ret = 0;
         }
-        else 
-            ret = -ESRCH;
     }
     break;
 
@@ -619,31 +611,31 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
         int num = op->u.getpageframeinfo2.num;
         domid_t dom = op->u.getpageframeinfo2.domain;
         unsigned long *s_ptr = (unsigned long*) op->u.getpageframeinfo2.array;
-        struct domain *p;
+        struct domain *d;
         unsigned long l_arr[GPF2_BATCH];
         ret = -ESRCH;
 
-        if ( unlikely((p = find_domain_by_id(dom)) == NULL) )
+        if ( unlikely((d = find_domain_by_id(dom)) == NULL) )
             break;
 
-        if ( unlikely(num>1024) )
+        if ( unlikely(num > 1024) )
         {
             ret = -E2BIG;
             break;
         }
  
-        ret = 0;    
-        for(n=0;n<num;)
+        ret = 0;
+        for( n = 0; n < num; )
         {
             int k = ((num-n)>GPF2_BATCH)?GPF2_BATCH:(num-n);
 
-            if( copy_from_user( l_arr, &s_ptr[n], k*sizeof(unsigned long) ) )
+            if ( copy_from_user(l_arr, &s_ptr[n], k*sizeof(unsigned long)) )
             {
                 ret = -EINVAL;
                 break;
             }
      
-            for(j=0;j<k;j++)
+            for( j = 0; j < k; j++ )
             {      
                 struct pfn_info *page;
                 unsigned long mfn = l_arr[j];
@@ -653,7 +645,7 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
 
                 page = &frame_table[mfn];
   
-                if ( likely(get_page(page, p)) )
+                if ( likely(get_page(page, d)) )
                 {
                     unsigned long type = 0;
                     switch( page->type_and_flags & PGT_type_mask )
@@ -682,17 +674,16 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
 
             }
 
-            if( copy_to_user( &s_ptr[n], l_arr, k*sizeof(unsigned long) ) )
+            if ( copy_to_user(&s_ptr[n], l_arr, k*sizeof(unsigned long)) )
             {
                 ret = -EINVAL;
                 break;
             }
 
-            n+=j;     
+            n += j;
         }
 
-        put_domain(p);
-
+        put_domain(d);
     }
     break;
 
index 37f866113e3f5c4d00c7d96f72849067119c47c0..d6a43a474602f80439f462e37a3b7700d4449ef9 100644 (file)
@@ -204,12 +204,7 @@ void domain_suspend(u8 reason)
         machine_restart(0);
     }
 
-    current->stop_code = reason;
-    memcpy(&current->shared_info->execution_context, 
-           get_execution_context(), 
-           sizeof(execution_context_t));
-    unlazy_fpu(current);
-    wmb(); /* All CPUs must see saved info when suspended. */
+    current->suspend_code = reason;
     set_bit(DF_SUSPENDED, &current->flags);
 
     d = find_domain_by_id(0);
index e72eb4e0005cf318cc6f3a4153dcafec13ae66d5..d1cf9c1fd5d5b004563cfacb8b04e8f376f2a7f2 100644 (file)
@@ -83,18 +83,16 @@ typedef struct {
     /* IN variables. */
     domid_t  domain;                  /*  0 */ /* NB. IN/OUT variable. */
     /* OUT variables. */
-#define DOMSTATE_CRASHED     0 /* Crashed domain; frozen for postmortem.     */
-#define DOMSTATE_SUSPENDED   1 /* Domain voluntarily halted it execution.    */
-#define DOMSTATE_PAUSED      2 /* Currently paused (forced non-schedulable). */
-#define DOMSTATE_BLOCKED     3 /* Currently blocked pending a wake-up event. */
-#define DOMSTATE_RUNNABLE    4 /* Currently runnable.                        */
-#define DOMSTATE_RUNNING     5 /* Currently running.                         */
-#define DOMFLAGS_STATEMASK   7 /* One of the DOMSTATE_??? values.            */
-#define DOMFLAGS_STATESHIFT  0
-#define DOMFLAGS_CPUMASK   255 /* CPU to which this domain is bound.         */
-#define DOMFLAGS_CPUSHIFT    3
-#define DOMFLAGS_GUESTMASK 255 /* DOMSTATE_STOPPED -> Guest-supplied code.   */
-#define DOMFLAGS_GUESTSHIFT 11
+#define DOMFLAGS_DYING     (1<<0) /* Domain is scheduled to die.             */
+#define DOMFLAGS_CRASHED   (1<<1) /* Crashed domain; frozen for postmortem.  */
+#define DOMFLAGS_SUSPENDED (1<<2) /* Domain voluntarily halted it execution. */
+#define DOMFLAGS_STOPPED   (1<<3) /* Currently stopped by control software.  */
+#define DOMFLAGS_BLOCKED   (1<<4) /* Currently blocked pending an event.     */
+#define DOMFLAGS_RUNNING   (1<<5) /* Domain is currently running.            */
+#define DOMFLAGS_CPUMASK      255 /* CPU to which this domain is bound.      */
+#define DOMFLAGS_CPUSHIFT       8
+#define DOMFLAGS_SUSPCODEMASK 255 /* DOMSTATE_SUSPENDED guest-supplied code. */
+#define DOMFLAGS_SUSPCODESHIFT 16
     u32      flags;                   /*  4 */
     u8       name[MAX_DOMAIN_NAME];   /*  8 */
     full_execution_context_t *ctxt;   /* 24 */ /* NB. IN/OUT variable. */
index 4fc3409da8cefc763e7ae0b39a296d1e88f92983..6a223663cabb912e7df25e5d0c541cbb7aa1e292 100644 (file)
@@ -96,7 +96,7 @@ struct domain
 
     /* Scheduling. */
     struct list_head run_list;
-    int              stop_code;     /* stop code from OS (if DF_STOPPED). */
+    int              suspend_code;  /* code value from OS (if DF_SUSPENDED). */
     s_time_t         lastschd;      /* time this domain was last scheduled */
     s_time_t         lastdeschd;    /* time this domain was last descheduled */
     s_time_t         cpu_time;      /* total CPU time received till now */